package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo7 {
    public static void main(String[] args) {
        try(Connection cnn=DBUtil.getConnection()) {
            String sql = "select count(*) count ,avg(salary) avg " +
                    "from teacher";
            Statement statement = cnn.createStatement();
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()){
                int count = rs.getInt("count");
                double avg = rs.getDouble("avg");
                System.out.println(count+" "+avg);
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
